<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Faktura filter form base class.
 *
 * @package    marketing
 * @subpackage filter
 * @author     Your name here
 */
class BaseFakturaFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'datum_fakturisanja'            => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'vrsta_dakture'                 => new sfWidgetFormFilterInput(),
      'nalog_prodaje_id'              => new sfWidgetFormPropelChoice(array('model' => 'NalogProdaje', 'add_empty' => true)),
      'ukupan_isnos_po_nabavnoj_ceni' => new sfWidgetFormFilterInput(),
      'ukupan_porez'                  => new sfWidgetFormFilterInput(),
      'transportni_troskovi'          => new sfWidgetFormFilterInput(),
      'ukupan_iznos_racuna'           => new sfWidgetFormFilterInput(),
      'profit'                        => new sfWidgetFormFilterInput(),
      'created_at'                    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'updated_at'                    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
      'deleted_at'                    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => true)),
    ));

    $this->setValidators(array(
      'datum_fakturisanja'            => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'vrsta_dakture'                 => new sfValidatorPass(array('required' => false)),
      'nalog_prodaje_id'              => new sfValidatorPropelChoice(array('required' => false, 'model' => 'NalogProdaje', 'column' => 'id')),
      'ukupan_isnos_po_nabavnoj_ceni' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'ukupan_porez'                  => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'transportni_troskovi'          => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'ukupan_iznos_racuna'           => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'profit'                        => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'created_at'                    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'                    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'deleted_at'                    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('faktura_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Faktura';
  }

  public function getFields()
  {
    return array(
      'id'                            => 'Number',
      'datum_fakturisanja'            => 'Date',
      'vrsta_dakture'                 => 'Text',
      'nalog_prodaje_id'              => 'ForeignKey',
      'ukupan_isnos_po_nabavnoj_ceni' => 'Number',
      'ukupan_porez'                  => 'Number',
      'transportni_troskovi'          => 'Number',
      'ukupan_iznos_racuna'           => 'Number',
      'profit'                        => 'Number',
      'created_at'                    => 'Date',
      'updated_at'                    => 'Date',
      'deleted_at'                    => 'Date',
    );
  }
}
